package com.game.backend.service.impl.pk;

import com.game.backend.consumer.WebSocketServer;
import com.game.backend.consumer.utils.Game;
import com.game.backend.service.pk.ReceiveBotMoveService;
import org.springframework.stereotype.Service;

@Service
public class ReceiveBotMoveServiceImpl implements ReceiveBotMoveService {
    @Override
    public String receiveBotMove(Integer userId, Integer direction) {
        System.out.println("receive bot move:"+ userId + " "+direction+" ");
        if(WebSocketServer.users.get(userId).game != null){
            Game game =WebSocketServer.users.get(userId).game;
            if(game.getPlayerA().getId().equals(userId)){
                game.setNextStepA(direction);
            }else if(game.getPlayerB().getId().equals(userId)){
                game.setNextStepB(direction);
            }
        }
        return "receive bot move success";
    }
}
